Repository navigation
feat(cluster): split a cross-slot SSUBSCRIBE per slot - #134
Merged
Merged
Conversation
The server requires one slot per SSUBSCRIBE, and the client refused a cross-slot one with `MismatchedKeySlots`. A shard subscription is per channel, so nothing is atomic about subscribing to several at once: the command is now cut per slot like SUNSUBSCRIBE already is, each slice going to the master owning its slot. The router matches confirmations by name, so the caller is answered once every master has confirmed. The documentation of `PubSubCommands::ssubscribe` described SUBSCRIBE and linked to it; it now describes shard channels and the per-slot split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jo8jBqM8KTsnpJz9oRkK5G
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The server requires one slot per
SSUBSCRIBE, and the client refused a cross-slot one withMismatchedKeySlots. Soclient.ssubscribe(["doc:{a}", "doc:{b}"]), the exact reproduction of the original report, failed outright, while the matchingSUNSUBSCRIBEhas been split per slot since #132.Change
A shard subscription is per channel, so nothing is atomic about subscribing to several at once. A
SSUBSCRIBEnaming several slots is now routed like a cross-slotSUNSUBSCRIBE: one slice per slot, each to the master owning it (through therouteclassifier from #133, socheck_routableaccepts it too). The router matches confirmations by name, so the caller is answered once every master has confirmed.The documentation of
PubSubCommands::ssubscribedescribedSUBSCRIBEand linked to it; it now describes shard channels and the per-slot split.Listed under Changed in the changelog: it is a visible behaviour change (an error became a success), not a fix.
Trade-off
As with a plain
SUBSCRIBE, which is already split per node, a hard failure on one slice (not a redirection, which the multi-shard path replays) can leave the other slices subscribed while the caller gets an error. Refusing cross-slot subscriptions outright avoided that, at the cost of the API the report expected.Tests
a_cross_slot_ssubscribe_is_split_per_slot_in_cluster: the report's reproduction run to the end. It subscribes to two slots on two masters, receives from both, drops, waits until no master holds the channels, and repeats. Fails onmainwithMismatchedKeySlots, passes here.a_refused_cross_slot_ssubscribe_leaves_the_client_usablefrom fix(cluster): refuse an unroutable command before recording anything #133, whose premise (a refusedSSUBSCRIBE) no longer exists. The routing-refusal path is still covered bya_pipeline_with_a_cross_slot_command_runs_nothing.-D warnings,./run_tests.sh --hermetic, and the cross-slot and pub/sub tests on a local 3-master cluster pass.Generated by Claude Code